package jltx.fragmentpageframework.simple.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import java.util.List;

import jltx.fragmentpageframework.simple.fragment.pager.NewsChildFragment;

/**
 * @author jltxseo
 *         Created by junlintianxia on 2017/05/22.
 */

public class NewsTabPagerAdapter extends FragmentStatePagerAdapter{
    private List<String> titles;

    public NewsTabPagerAdapter(FragmentManager fm, List<String> titles) {
        super(fm);
        this.titles = titles;
    }

    @Override
    public Fragment getItem(int position) {
        NewsChildFragment childFragment = NewsChildFragment.newInstance(position,titles.get(position));
        return childFragment;
    }

    @Override
    public int getCount() {
        return titles == null ? 0 : titles.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles.get(position);
    }
}
